from tortoise import fields
from datetime import datetime
from .base import BaseModel, TimestampMixin


class SysJobLog(BaseModel, TimestampMixin):
    """定时任务调度日志表"""

    job_log_id = fields.IntField(pk=True, description="任务日志ID")

    job_name = fields.CharField(max_length=64, description="任务名称")

    job_group = fields.CharField(max_length=64, description="任务组名")

    invoke_target = fields.CharField(max_length=500, description="调用目标字符串")

    job_message = fields.CharField(max_length=500, null=True, description="日志信息")

    exec_status = fields.CharField(max_length=1, null=True, description="执行状态（0正常 1失败）")

    status = fields.CharField(max_length=1, null=True, description="状态（0正常 2删除）")

    exception_info = fields.CharField(max_length=2000, null=True, description="异常信息")

    create_by = fields.CharField(max_length=64, null=True, description="创建者")

    create_time = fields.DatetimeField(null=True, description="创建时间")

    update_by = fields.CharField(max_length=64, null=True, description="更新者")

    update_time = fields.DatetimeField(null=True, description="更新时间")

    remark = fields.CharField(max_length=500, null=True, description="备注信息")

    class Meta:
        table = "sys_job_log"

    def __str__(self):
        return f"{self.job_log_id}"